<{include file="../common/header.tpl"}>
<table width="100%" border="0" cellspacing="0">
 <tr>
       <td width="13%" valign="top">
           <{include file="../common/left.tpl"}>
       </td>
       <td width="87%" valign="top">

               <table width="100%" border="0" cellspacing="0">
                 <tr>
                       <td>
                            <div class="subnav">
                                <div class="content-menu ib-a blue line-x"> <a href="/webadmin/group/list"><em>用户组管理</em></a><span>|</span><a class="on" href="javascript:;"><em><{$op_name}></em></a> </div>
                            </div>
                            <div class="pad_10">
                              <div class="table-list">
                                    <div class="common-form">
                                        <form name="myform" action="<{if $info}>/webadmin/group/doedit<{else}>/webadmin/group/doadd<{/if}>" method="post" autocomplete="off" id="myform">
                                        <table width="100%" class="table_form contentWrap">
                                        <tbody>
                                        <tr>
                                        <td>群组名称</td> 
                                        <td><input type="text" name="group_name" value="<{$info.group_name}>" class="input-text" id="rolename"></td>
                                        </tr>
                                        <tr>
                                        <td>群组描述</td>
                                        <td><textarea name="group_describe" rows="2" cols="20" id="description" class="inputtext" style="height:100px;width:500px;"><{$info.group_describe}></textarea></td>
                                        </tr>
                                        <tr>
                                            <td>权限设置</td>
                                            <td>
                                                <input type="checkbox" id="button" name="selall" value="*" <{if $info&&$info['group_auth']=='*'}>checked="checked"<{/if}> />所有权限
                                                <div id="checked">
                                                <table cellspacing="0" border="0" width="100%">
                                                    <tbody>
                                                    <{foreach $auth as $key => $val}>
                                                    <tr>
                                                      <td bgcolor="#f9f9f9"><strong><{$val.name}></strong></td>
                                                    </tr>
                                                    <tr>
                                                      <td height="40">
                                                          <{if $val.sub}>
                                                          <{foreach $val.sub as $k => $v}>
                                                          <label><input type="checkbox" value="<{$v.action}>" name="group_auth[]" class="auth_list" <{if $info&&($info['group_auth']=='*'||$v.action|check_auth:$info['group_auth'])}>checked="checked"<{/if}>><{$v.name}></label>
                                                          <{/foreach}>
                                                            <{/if}>
                                                      </td>
                                                    </tr>
                                                    <{/foreach}>
                                                  </tbody>
                                                </table>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                        <td>是否启用</td>
                                        <td>
                                            <input type="radio" name="status" value="1" <{if $info.status==1}>checked="checked"<{/if}>> 启用  
                                            <label><input type="radio" name="status" <{if $info.status==0}>checked="checked"<{/if}> value="0">禁止</label></td>
                                        </tr>
                                        </tbody>
                                        </table>

                                        <div class="bk15"></div>
                                        <input name="group_id" value="<{$info.group_id}>" type="hidden"/>
                                        <input name="dosubmit" type="submit" value="提交" class="button">
                                        </form>
                                        </div>
                              </div>
                            </div>

                       </td>
                 </tr>
               </table>
       </td>
 </tr>
</table>
<script type="text/javascript">
    (function($){
	$.fn.checkBox = function(state){
		this.each(function(){
			switch (state) {
				case 'all':
					$(this).prop("checked",'checked');
					break;
				case 'none':
					$(this).prop("checked",'');
					break;
				case 'toggle':
					$(this).prop("checked",!this.checked);
					break;
			}
		});
	};
	$.fn.checkedValue = function(){
		var str=[];
		this.each(function(){
			str+=$(this).val()+",";
		})
		return str;
	};
        $('.auth_list').click(function(){
            $('.auth_list').each(function(){
                if ($(this).prop('checked')==false){
                    $('#button').prop('checked', '');return false;
                }
            });
        });

})(jQuery);

$(document).ready(function(){
    $("#button").bind("click",function(){
        if ($(this).is(':checked')){
            $("#checked input[type=checkbox]").checkBox("all");
        } else {
            $("#checked input[type=checkbox]").checkBox("none");
        }

    });
    $('#myform').submit(function(){
        var rolename = $('#rolename').val();
        if (rolename == '') {
            $('#rolename').focus();alert('用户组名称不能为空！');return false;
        }
        if($('input[type=checkbox]:checked').length==0){
            alert('未选择任何权限');return false;
        }
        return true;
    });
});
</script>
<{include file="../common/footer.tpl"}>